package org.dev.app.controller;

import lombok.extern.slf4j.Slf4j;
import org.dev.app.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wangzhuangzhuang
 * @Description:
 * @date 2022-05-26 16:12
 */
@RestController
@Slf4j
public class DeptController {

	@Autowired
	private DeptService deptService;
	@Value("${server.port}")
	private String serverPort;

	@RequestMapping(value = "/dept/hystrix/ok/{id}")
	public String deptInfo_Ok(@PathVariable("id") Integer id) {
		String result = deptService.deptInfo_Ok(id);
		log.info("端口号： " + serverPort + " result: " + result);
		return result + " , 端口号： " + serverPort;
	}

	// Hystrix服务超时降级
	@RequestMapping(value = "/dept/hystrix/timeout/{id}")
	public String deptInfo_Timeout(@PathVariable("id") Integer id) {
		String result = deptService.deptInfo_Timeout(id);
		log.info("端口号： " + serverPort + " result: " + result);
		return result + " , 端口号： " + serverPort;
	}
}